<?php
if(!$login_do) include("config.php");
if($_POST['session_id']){
	//////////////////////////////////////////////////////////////////////////////////////
	//获取姓名学号
	$snoopy1 = new Snoopy;
	//模拟HEADER
	$snoopy1->cookies['ASP.NET_SessionId'] = $_SESSION["ASP_NET_SessionId"];
	//获取分析表单
	if( $_POST['user_type'] == 'STU' ){
		//echo 1;
		$snoopy1->fetch($personurl);
	}
	if( $_POST['user_type'] == 'TEA' ){
		//echo 2; 
		$snoopy1->fetch($personurl_tea);
	}
	//$snoopy1->fetch($personurl);
	$res1 = $snoopy1->results;

	//超时返回
	if ($snoopy1->status != '200' || $snoopy1->timed_out) {
    	echo json_err(1,"页面获取超时！");
    	return;
	}
	//转码以便查找错误
	$snoopy_results = mb_convert_encoding($snoopy1->results, 'utf-8', 'gbk');
	if(stripos($snoopy_results,"您正查看的此页已过期")){
    	echo json_err(5,"session_id错误或超时！");
    	return;
	}

	$res1_html = new simple_html_dom();
	$res1_html->load(iconv('GB2312', 'UTF-8//IGNORE', $res1));
	$res1_tds = $res1_html->find('td');
	//var_dump($res1_tds[5]->innertext);
	if( $_POST['user_type'] == 'STU' ){
		$xh = strip_tags($res1_tds[2]->innertext);
		$xm = strip_tags($res1_tds[4]->innertext);
	}
	if( $_POST['user_type'] == 'TEA' ){
		$xh = strip_tags($res1_tds[3]->innertext);
		$xm = strip_tags($res1_tds[5]->innertext);
	}
	$res1_html->clear();
	$table['ct_info'] = array(
		'xm'=>$xm,
		'xh'=>$xh,
	);
	//noapi调用
	if($_POST['noapi']){
		echo "姓名：".$xm."    学号：".$xh;
		return;
	}
	echo json_encode($table['ct_info']);
	return;
	//记录
	//$query = "UPDATE log SET user_id='".$_POST['UserID']."',is_ok='".$is_ok."',num='".$txt_xm."' WHERE id='".$_SESSION['insert_id']."'";
	//mysql_query($query);
}else{
	echo json_err(2,'提交数据不全!');
	return;
}
//mysql_close($link);
?>